Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pathe

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathe

Universal filesystem path utils

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11M
decreased by-3.45%
Maintainers
2
Weekly downloads
 
Created

What is pathe?

The 'pathe' npm package is a utility library for handling and manipulating file paths in Node.js. It provides a variety of functions to work with file paths in a more convenient and readable way.

What are pathe's main functionalities?

Join Paths

The 'join' function concatenates multiple path segments into a single path, normalizing the resulting path.

const { join } = require('pathe');
const fullPath = join('/foo', 'bar', 'baz/asdf', 'quux', '..');
console.log(fullPath); // '/foo/bar/baz/asdf'

Resolve Paths

The 'resolve' function resolves a sequence of paths or path segments into an absolute path.

const { resolve } = require('pathe');
const resolvedPath = resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile');
console.log(resolvedPath); // '/tmp/subfile'

Normalize Paths

The 'normalize' function normalizes the given path, resolving '..' and '.' segments.

const { normalize } = require('pathe');
const normalizedPath = normalize('/foo/bar//baz/asdf/quux/..');
console.log(normalizedPath); // '/foo/bar/baz/asdf'

Get Directory Name

The 'dirname' function returns the directory name of a path.

const { dirname } = require('pathe');
const dirName = dirname('/foo/bar/baz/asdf/quux');
console.log(dirName); // '/foo/bar/baz/asdf'

Get Base Name

The 'basename' function returns the last portion of a path, typically the file name.

const { basename } = require('pathe');
const baseName = basename('/foo/bar/baz/asdf/quux.html');
console.log(baseName); // 'quux.html'

Get Extension Name

The 'extname' function returns the extension of the path, from the last occurrence of the '.' character to end of string in the last portion of the path.

const { extname } = require('pathe');
const extName = extname('index.html');
console.log(extName); // '.html'

Other packages similar to pathe

FAQs

Package last updated on 10 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc